package com.demo.config.canal.test3;

import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author simon 策略上下文
 */
@Component
@AllArgsConstructor
public class TableStrategyContext {

	private final Map<String, TableOperationStrategy> tableStrategyMap = new ConcurrentHashMap<>();

	public TableStrategyContext(Map<String, TableOperationStrategy> strategyMap) {
		this.tableStrategyMap.clear();
		strategyMap.forEach((k, v) -> this.tableStrategyMap.put(k, v));
	}

	public TableOperationStrategy getResource(String tableName) {
		return tableStrategyMap.get(tableName);
	}

}
